package cn.zjnu.struts;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import cn.zjnu.DAO.EmployeesDAO;
import cn.zjnu.bean.Employees;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class EmployeesAction extends ActionSupport{
	private String DeptId=null;
	private String PY=null;
	private String CareerId=null;
	EmployeesDAO Employees=new EmployeesDAO();
	public String getDeptId() {
		return DeptId;
	}
	public void setDeptId(String deptId) {
		DeptId = deptId;
	}
	public String getPY() {
		return PY;
	}
	public void setPY(String pY) {
		PY = pY;
	}
	public String getCareerId() {
		return CareerId;
	}
	public void setCareerId(String careerId) {
		CareerId = careerId;
	}
	public String execute() throws ClassNotFoundException, SQLException{
		Employees.connect();
		ResultSet rs=Employees.Query(PY, DeptId, CareerId);
		List employees= new ArrayList<Employees>();
		while(rs.next()){
			String EmId,EmName,DeptId,ThreeDeptId,CareerId,CareerDate,DegreeId,LongMobile,ShortMobile,OfficePhone,Memo;
			EmId=rs.getString("EmId");
			EmName=rs.getString("EmName");
		    DeptId=rs.getString("DeptId");
			ThreeDeptId=rs.getString("ThreeDeptId");
			CareerId=rs.getString("CareerId");
			CareerDate=rs.getString("CareerDate");
			DegreeId=rs.getString("DegreeId");
			LongMobile=rs.getString("LongMobile");
			ShortMobile=rs.getString("ShortMobile");
			OfficePhone=rs.getString("OfficePhone");
			Memo=rs.getString("Memo");
			Employees employee=new Employees(EmId,EmName,DeptId,ThreeDeptId,CareerId,CareerDate,DegreeId,LongMobile,ShortMobile,OfficePhone,Memo); 
			employees.add(employee);
		}
		ActionContext ct=ActionContext.getContext();
		ct.put("employees", employees);
		return this.SUCCESS;
	}
}
